package com.wanxi.servlet.image;

import com.alibaba.fastjson2.JSONObject;
import com.wanxi.dto.ResultDTO;
import com.wanxi.service.ImageService;
import com.wanxi.service.Impl.ImageServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/image/find")
public class FindEnableImageServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        乱码处理、传输格式处理
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json");
//        调用service处理
        ImageService imageService=new ImageServiceImpl();
        ResultDTO resultDTO = imageService.findImage();
//        返回值给前端
        resp.getWriter().println(JSONObject.toJSONString(resultDTO));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
